<?




//同意加上and，然后去除左边的and就可以了。
if($_REQUEST['select_keywords'])
{
    $keywords=" and (m.nickname like '%".$_REQUEST['select_keywords']."%' )";
    $keywords_url="&select_keywords=".$_REQUEST['select_keywords'];
}
else
{
    $keywords="";
    $keywords_url="";
}


if($_REQUEST['select_startday'])
{
    $start_date= $_REQUEST['select_startday']." 00:00:00";
    $start_date_str=" and  em.add_date > '".$start_date."'";
    $start_date_url="&select_startday=".$_REQUEST['select_startday'];
}
else
{
    $start_date_str="";
    $start_date_url="";
}




if($_REQUEST['select_endday'])
{
    $end_date=$_REQUEST['select_endday']." 23:59:59";
    $end_date_str=" and em.add_date < '".$end_date."'";
    $end_date_url="&select_endday=".$_REQUEST['select_endday'];
}
else
{
    $end_date_str="";
    $end_date_url="";
}






if($sortorder)
{
    $sortorder="order by ".$sortorder;
}
else
{
    $sortorder="";
}

$pagenumber_url = "&nowpageid=" . $_REQUEST['nowpageid'];
$sortby_url     = "&sortby=" . $_REQUEST['sortby'];
$navitemed_url  = "&nav-itemed=" . $_REQUEST['nav-itemed'];
$system_part    = "&system_part=" . $_REQUEST['system_part'];
$term_nid       = "&term_nid=" . $_REQUEST['nid'];

$url_str=$keywords_url.$start_date_url.$end_date_url.$navitemed_url;
$select_str=$keywords.$start_date_str.$end_date_str.' ';

//设置需要搜索的表格的前缀后缀
    $table_Suffix = 'event_member';
    $table = $table_Prefix . $table_Suffix;
    $sqlstr="SELECT COUNT(em.nid) FROM  $table as em left join ".$table_Prefix ."member as m on m.nid = em.user_id where (em.nid > '0')  and event_nid = $nid  ".$select_str;


$query = do_query($sqlstr);
    $sum = mysqli_fetch_array($query)[0];

?>











<?php
//设置翻页代码相关内容

$nowpageid = 1;
$detailnum = 55; //每页显示多少个产品


if ($_REQUEST ['nowpageid']) {
    $nowpageid = $_REQUEST ['nowpageid'];
} else {
    $nowpageid = 1;
}


//计算一下结果，从那条数据开始显示
$detailstar = ($nowpageid - 1) * $detailnum;


if ($sum) {

    if ($sum < $detailnum) {
        $page_count = 1;
        $detailnum = $sum;
    } //如果总数据量小于$Pagenum,（pagenum作为每页显示数据的条数，）那么只有一页,而pagenum也更改为sum 


    else if ($sum % $detailnum) {
        $page_count = (int)($sum / $detailnum) + 1;
    }
    //取总数据量除以每页数的余数 
    //如果有余数，则页数等于总数据量除以每页数的结果取整再加一


    else {
        $page_count = $sum / $detailnum;
    }
    //如果没有余数，则页数等于总数据量除以每页数的结果 

} else {
    $page_count = 0;
    $detailnum = 0;
}


$lastpage = $page_count;
$prepage = $nowpageid - 1;
$nextpage = $nowpageid + 1;


if ($nowpageid == 1) {
    $prepage = 1;
}


if ($nowpageid == $page_count) {

    if ($sum <= $detailnum) //总数数据少于每页显示数目，就把循环改成总数数目
    {
        $detailnum = $sum;
        $nextpage = $nowpageid;
    } else {
        $nextpage = $nowpageid;
        $detailnum = fmod($sum, $detailnum);
        if ($detailnum == 0) //这个if是因为当数据正好30条，能除尽的话，最后一页就会因为fmod能整除的缘故，最后一页不显示数据
        {
            $detailnum = 15;
        }
    }
    //如果现在页数等于总页数（总页数上面求出，最后一页不够循环数的时候），那么最后一页的detailnum就会等于余下数据(不足一页)的数目.

}

//设置需要搜索的表格的排序项和升降项
$sort_by = "em.is_delete asc , em.nid";
$sort_order = "asc";
//设置需要搜索的表格的排序项和升降项


if ($_REQUEST ['sortby']) {
    $sort_by = $_REQUEST ['sortby'];
}


if ($_REQUEST ['sortorder']) {
    $sort_order = $_REQUEST ['sortorder'];
}




$sqlstr="select em.* , m.nickname, m.phone , m.headimgurl from $table as em left join ".$table_Prefix ."member as m on m.nid = em.user_id where (em.nid > '0')  and em.event_nid = '$nid'  ".$select_str." ORDER BY $sort_by $sort_order  limit $detailstar , $detailnum";
$result = do_query($sqlstr);


while ($row = mysqli_fetch_assoc($result)) {

    $order_info = select_one_line_all_items($table_Prefix.'order_info',' order_id = '.$row['order_id']);

    echo $row['event_id'];
    $h5apply    = select_one_line_all_items($table_Prefix.'h5_apply',' member_nid = '.$row['user_id'].' and event_nid = '.$_REQUEST['nid']);

    $row['order_info']   =  $order_info;
    $row['h5apply']   =  $h5apply;

    $detail[] = $row;

}

mysqli_close($con);


?>